package marke.barak.windows.composit;

import marek.barak.classes.User;
import marek.barak.windows.main.main;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

public class chooseUser extends Composite {
	Combo cmbChooseUser;
	

	/**
	 * Create the composite.
	 * @param parent
	 * @param style
	 */
	public chooseUser(Composite parent, int style) {
		super(parent, style);
		
		cmbChooseUser = new Combo(this, SWT.NONE);
		cmbChooseUser.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				try{
				main.users.setCurentUser(main.users.getAllUsers().get(cmbChooseUser.getSelectionIndex()));
				main.setShellName(getShell(), "Measurements User: "+main.users.getCurentUser().toString());
				}catch(Exception ex){
					System.err.println(ex.toString());
				}
			}
		});
		cmbChooseUser.setBounds(10, 10, 93, 21);
		for(User u: main.users.getAllUsers()){
		cmbChooseUser.add(u.toString());
		}

	}

	@Override
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	}
}
